from flask import Flask, jsonify, render_template
import pandas as pd

app = Flask(__name__)

# 读取 CSV 文件并返回数据
def read_data_from_csv(file_path):
    # 读取 CSV 文件
    data = pd.read_csv(file_path)
    # 转换为 JSON 格式
    result = {
        "x": data['x'].tolist(),
        "deflections_point": data['deflections_point'].tolist(),
        "deflections_dist": data['deflections_dist'].tolist()
    }
    return result

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/plot')
def plot():
    return render_template('plot.html')

@app.route('/product')
def product():
    return render_template('product.html')

@app.route('/team')
def team():
    return render_template('team.html')

@app.route('/get_data')
def get_data():
    # 假设数据文件路径为 'data.csv'
    file_path = 'data.csv'
    data = read_data_from_csv(file_path)
    return jsonify(data)

if __name__ == '__main__':
    app.run(debug=True, port=8080)